<template>
  <div> 
    <span v-if='defaultVal.length == 0'>
      <span v-if='!isAdd && !isLook && uploadAction' class='go-upload' @click='$emit("upload")'>上传</span>
    </span>
    <span v-else class='has-data'>
      <span v-if='isEdit' class='edit-content'>
        {{defaultVal}}<a-icon type="close" class='icon-close' @click='delDeliver'/>
      </span>
      <a-tooltip v-else>
        <template slot="title">
          {{defaultVal}}
        </template>
        <span  class='one-warp' @click='goDetail'>{{defaultVal}}</span>
      </a-tooltip>
    </span>
  </div>
</template>
<script>
import copyACtion from '@/views/singleProject/fileSingle/el-common-js/copy'
import {mapGetters} from 'vuex'
export default {
  mixins: [copyACtion],
  props: {
    uploadAction: {
      type: Boolean,
      default: false
    },
    columnInfo: {
      type: Object,
      default: () => {}
    },
    data: {
      type: Object,
      default: () => {}
    },
    index: {
      default: 0
    },
    updateRows: {
      type: Array,
      default: () => []
    },
    isLook: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    ...mapGetters({
      'fileSingleData': 'fileSingle'
    }),
    isAdd() {
      return this.data.oid.indexOf('add') != -1
    },
    defaultVal() {
      return this.data[this.columnInfo.dataIndex]
    },
    isEdit() {
      return this.updateRows.includes(this.index)
    }
  },
  methods: {
    delDeliver() {
      //调用修改交付物接口  subjectOid 传空
      this.$emit('delDeliver')
    },
    goDetail() {
      let result = {
        oid: this.data.subjectOid,
        state: this.data.subjectState
      }
      if (result.oid.includes('ProjectTaskBook')) {
        // 任务书详情页
        this.$router.push({path: "projectPaper/mainTaskBook"})
      } else {
        this.fileSingleData.tableArr = [result]
        this.setFileSingle(this.fileSingleData)
        this.setFileSingleTableItem({oid: result.oid, state: result.state})
        this.$store.commit('SET_PROJECT_FILE_TITLE', '')
        this.$router.push({path: "fileSingle/examineProject"})
      }
    }
  }
}
</script>
<style scoped lang='less'>
.go-upload {
  display: inline-block;
  border: 1px solid #386bd7;
  background: #386bd7;
  color: #fff;
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
}
.has-data {
  display: inline-block;
  width: 100%
}
.edit-content {
  background: #fff;
  position: relative;
  display: inline-block;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0 35px 0 5px;
  vertical-align: middle;
  width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 32px;
}
.icon-close {
  cursor: pointer;
  position: absolute;
  right: 5px;
  top: 8px;
}
.one-warp {
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  color: rgb(56, 107, 215);
}
</style>